/* 两头堵模型 */
//去掉首尾指定元素
int fun(char *p, int *n)
{ //char *p= "      basldsldf    ";
	if (p == NULL || n == NULL)
	{
		return -1;
	}
	int begin = 0;			 //首元素下标
	int end = strlen(p) - 1; //尾元素下标
	while (p[begin] == ' ' && p[begin] != 0)
	{ //p[begin]==' '
		begin++;
	}

	while (p[end] == ' ' && end > 0)
	{
		end--;
	}
	if (end == 0)
	{
		return = -2;
	}
	//非空元素个数
	*n = end - begin + 1;
	return 0;
}
int main()
{
	char *p = "      basldsldf    ";
	int ret = 0;
	int n = 0;
	ret = fun(p, &n);
	if (ret != 0)
	{
		return ret;
	}
	return 0;
}
